﻿
Partial Class users_messages_Default
    Inherits System.Web.UI.Page

    Private _UserID As Integer
    Public Property UserID() As Integer
        Get
            Return _UserID
        End Get
        Set(ByVal value As Integer)
            _UserID = value
        End Set
    End Property

    Private _imgRead As Image
    Public Property imgRead() As Image
        Get
            Return _imgRead
        End Get
        Set(ByVal value As Image)
            _imgRead = value
        End Set
    End Property

    Private _imgUnread As Image
    Public Property imgUnread() As Image
        Get
            Return _imgUnread
        End Get
        Set(ByVal value As Image)
            _imgUnread = value
        End Set
    End Property


    Dim messageAdapter As New MainDbTableAdapters.MessagesTableAdapter()

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim ID As FormsIdentity = DirectCast(HttpContext.Current.User.Identity, FormsIdentity)
        UserID = ID.Name
        gridMessages.DataSource = messageAdapter.GetMessagesByUserID(ID.Name)
        gridMessages.DataBind()

    End Sub

    Protected Sub gridMessages_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridMessages.DataBound

    End Sub



    Protected Sub gridMessages_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridMessages.RowCreated
        If e.Row.RowIndex > -1 Then
            imgRead = CType(e.Row.Cells(0).FindControl("imgRead"), Image)
            imgUnread = CType(e.Row.Cells(0).FindControl("imgUnread"), Image)
            imgUnread.Visible = False
            imgRead.Visible = False

            'lblText.text += e.Row.Cells(0).Text

            'imgRead.Visible = True


            'imgRead = CType(e.Row.Cells(0).FindControl("imgRead"), Image)
            'imgUnread = CType(e.Row.Cells(0).FindControl("imgUnread"), Image)
            'imgRead.Visible = True
            'imgUnread.Visible = False

        End If
    End Sub

    Protected Sub gridMessages_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridMessages.SelectedIndexChanged
        Dim messageID As Integer = gridMessages.SelectedDataKey.Value

        messageAdapter.MessageRead(True, messageID)

        Response.Redirect("readMessage.aspx?MessageID=" & messageID)
    End Sub


End Class
Message.aspx?MessageID=" & messageID)
    End Sub


End Class
